package it.polimi.sartori_daniello_picca.meteocal.gui;

import it.polimi.sartori_daniello_picca.meteocal.boundary.UserManager;
import it.polimi.sartori_daniello_picca.meteocal.entity.Users;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;

/**
 *
 * @author ale
 */

@Named(value="RegistrationBean")
@RequestScoped
public class RegistrationBean {
      
      @EJB
    private UserManager um;

    private Users user;

    public RegistrationBean() {
    }

    public Users getUser() {
        if (user == null) {
            user = new Users();
        }
        return user;
    }

    public void setUser(Users user) {
        this.user = user;
    }

    public String register() {
        um.save(user);
        return "login?faces-redirect=true";
    }
}
